function e(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

Object.defineProperty(exports, "__esModule", {
    value: !0
});

var t = e(require("env")), a = e(require("Base64"));

require("hmac"), require("sha1");

var i = e(require("crypto")), r = e(require("../../public/lib/md5.min"));

exports.default = {
    uploadFile: function(e, a, i, s, o) {
        if (!e || e.length < 9) wx.showModal({
            title: "视频错误",
            content: "请重试",
            showCancel: !1
        }); else {
            var l = (0, r.default)(new Date().getTime()) + i, d = a + l, c = t.default.aliyunServerURL, f = t.default.accessid, g = u(), v = n(g);
            wx.showLoading({
                title: "上传视频中..."
            }), wx.uploadFile({
                url: c,
                filePath: e,
                name: "file",
                formData: {
                    key: d,
                    OSSAccessKeyId: f,
                    policy: g,
                    Signature: v,
                    success_action_status: "200"
                },
                success: function(e) {
                    if (200 === e.statusCode) {
                        var a = t.default.aliyunServerURL + d;
                        s(a, l), wx.hideLoading();
                    } else o(new Error("上传错误:" + JSON.stringify(e)));
                },
                fail: function(e) {
                    e.wxaddinfo = c, o(e), wx.hideLoading();
                }
            });
        }
    }
};

var u = function() {
    var e = new Date();
    e.setHours(e.getHours() + t.default.timeout);
    var i = {
        expiration: e.toISOString(),
        conditions: [ [ "content-length-range", 0, 20971520 ] ]
    };
    return a.default.encode(JSON.stringify(i));
}, n = function(e) {
    var a = t.default.accesskey, r = i.default.HMAC(i.default.SHA1, e, a, {
        asBytes: !0
    });
    return i.default.util.bytesToBase64(r);
};